//
//  LLWeekView.swift
//  liliiosPorject
//
//  Created by liuzhu on 2018/12/26.
//  Copyright © 2018 liuzhu. All rights reserved.
//

import UIKit

class LLWeekView: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        addWeekLabel()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func addWeekLabel(){
        for la in weeks{
            self.addSubview(la)
        }
        xmg_HorizontalTile(views: weeks, insets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0))
    }
    
    public var currentWeek:Int?{
        didSet{
            for i in 1...7{
                let la = weeks[i-1]
                if i == currentWeek{
                    la.textColor = UIColor.red
                }else{
                    la.textColor = UIColor.darkGray
                }
            }
        }
    }
    
    //MARK:- 懒加载
    private lazy var weeks:[UILabel] = {
        var las = [UILabel]()
        for i in 1...7{
            let la = UILabel()
            la.textAlignment = NSTextAlignment.center
            la.textColor = UIColor.darkGray
            la.font = UIFont.systemFont(ofSize: 13)
            switch i{
            case 1:
                la.text = "星期日"
                break
            case 2:
                la.text = "星期一"
                break
            case 3:
                la.text = "星期二"
                break
            case 4:
                la.text = "星期三"
                break
            case 5:
                la.text = "星期四"
                break
            case 6:
                la.text = "星期五"
                break
            case 7:
                la.text = "星期六"
                break
            default:
                break
            }
            las.append(la)
        }
        return las
    }()
}
